package com.codingday.app;

import java.util.Date;

import android.content.Context;
import android.location.Location;

public class TODO {

	long TODO_ID;
	Date createdDate;
	Date completedDate;
	
	boolean isEnabled = true;
	String title = null;
	String desc = null;
	
	double latitude;
	double longitude;
	int radius;	// meter
	
	boolean isPaused;
	boolean isCompleted;
	
	//Location location;
	
	public TODO(){
		isEnabled = true;
	}
	
	public TODO(String title, String desc){
		this.title = title;
		this.desc = desc;
		radius = 300;
		isPaused =  false;
		
	}
	
	public void setID(long ID){
		TODO_ID = ID;
		//createdDate = date;
	}
	
	public long getID(){
		return TODO_ID;
	}
	
	public String getTitle(){
		return title;
	}
	public String getDesc(){
		return desc;
	}
	public void setTitle(String title){
		this.title = title;
	}
	public void setDesc(String desc){
		this.desc = desc;
	}
	
	public void setLocation(double latitude, double longitude, int radius){
		this.latitude = latitude;
		this.longitude = longitude;
		this.radius = radius;
		
		//double cur_latitude = MyLocationManager.getInstance(context).getLatitude();
		//double cur_longitude = MyLocationManager.getInstance(context).getLatitude();
		float distance = MyLocationManager.getInstance(GeoAlarm.getContext()).getDistanceTo(latitude, longitude);
		
		if(distance <= radius){
			isPaused = true;
		}
	}


	public boolean isPausedByInitial(){
		return isPaused;
	}
	public void resumeFromInitialPause(boolean resume){
		isPaused = !resume;
	}
	

	public int getRadius(){
		return radius;
	}
	
	public float getDistanceTo(double toLatitude, double toLongitude){
		//float distance = 0;
		float[] results = new float[3];
		Location.distanceBetween(this.latitude, this.longitude, toLatitude, toLongitude, results);
		return results[0];
	}
	
	public double getLatitude(){
		return latitude;
	}
	public double getLongitude(){
		return longitude;
	}
	public boolean isCompleted(){
		return isCompleted;
	}
	public boolean isEnabled(){
		return isEnabled;
	}
	
	public void setCompleted(boolean completed){
		this.isCompleted = completed;
		if(completed){
			this.isEnabled = false;
		}
	}
	
	public void Enable(){
		isEnabled = true;
	}
	public void Disable(){
		isEnabled = false;
	}
	
	public void setCreatedDate(Date date){
		this.createdDate = date;
	}
	public void setCompletedDate(Date date){
		this.completedDate = date;
	}
	
	public Date getCreatedDate(){
		return this.createdDate;
	}
	public Date getCompletedDate(){
		return this.completedDate;
	}
	
}
